-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyProject.java
More file actions
155 lines (129 loc) · 3.56 KB
/
MyProject.java
File metadata and controls
155 lines (129 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package swing;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import database.*;
import java_side.*;
public class MyProject extends JFrame {
// static variables
/**
* 세션용 아이디 정보
*/
public static String UserId = "";
/**
* 최상위 레이아웃 패널
*/
public static JLayeredPane ChangePanel;
public static JPanel LoginPanel;
public static SelectMenuPanel smp = new SelectMenuPanel();
// Component
private JPanel MainPanel;
private JPanel Book_MS_Panel;
private JPanel Reserv_Panel;
private JButton btnNewButton_1;
private JButton btn_Reserv;
private JButton returnLogin;
private JButton btn_Reserv_ms;
private LoginPanel lp;
JLabel[] selectedTable = new JLabel[5];
// DB관련
public Connection mainConn = null;
public static DML dml = null;
public MyProject() {
try {
mainConn = DBConnManager.getConn("ai", "1234");
dml = new DML();
if (mainConn != null) {
initaialize();
setEvent();
} else
JOptionPane.showMessageDialog(null, "no DB connection", "Error", JOptionPane.ERROR_MESSAGE);
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (mainConn != null)
try {
DBConnManager.disconn();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
private void initaialize() {
getContentPane().setLayout(null);
ChangePanel = new JLayeredPane();
ChangePanel.setBounds(0, 0, 1000, 700);
getContentPane().add(ChangePanel);
lp = new LoginPanel();
ChangePanel.add(lp);
MainPanel = new JPanel();
MainPanel.setBounds(0, 0, 1000, 700);
MainPanel.setLayout(null);
btnNewButton_1 = new JButton("도서 검색");
btnNewButton_1.setBounds(561, 78, 97, 23);
MainPanel.add(btnNewButton_1);
btn_Reserv = new JButton("예약 하기");
btn_Reserv.setBounds(664, 78, 97, 23);
MainPanel.add(btn_Reserv);
Reserv_Panel = new JPanel();
Reserv_Panel.setBounds(0, 0, 1000, 700);
// ChangePanel.add(Reserv_Panel);
Reserv_Panel.setLayout(null);
returnLogin = new JButton("시작화면으로");
returnLogin.setBounds(664, 78, 97, 23);
Reserv_Panel.add(returnLogin);
btn_Reserv_ms = new JButton("예약 관리");
btn_Reserv_ms.setBounds(664, 101, 97, 23);
MainPanel.add(btn_Reserv_ms);
this.setSize(1000, 700);
this.setVisible(true);
this.setLocation(500, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private void setEvent() {
btn_Reserv.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switchTopPanel(Reserv_Panel);
}
});
returnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switchTopPanel(LoginPanel);
}
});
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switchTopPanel(Book_MS_Panel);
}
});
btn_Reserv_ms.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
switchTopPanel(smp);
}
});
}
// FIXME: 시작!
public static void main(String[] args) {
new MyProject();
}
/**
* 현재 최상단 레이아웃의 JPanel을 제거하고, 매개변수로 대체.
*
* @param pan
* @author jaemoonnlee
*/
//TODO 화면전환 1번
public static void switchTopPanel(JPanel pan) {
ChangePanel.removeAll();
ChangePanel.add(pan);
ChangePanel.repaint();
ChangePanel.revalidate();
}
}